<?php  
require "ConnDB.php";
require "Model.php";
  class VideoModel extends Model{
  	
    public function __construct(){
       parent::__construct();
    }

  	function getVideoList(){
  		// $data=array(array('vname'=>'微微一笑很倾城','intro'=>'微微一笑很倾城'),array('vname'=>'你好漂亮','intro'=>'你好漂亮'));
  		 $sql="select * from videos";
         $data=$this->conn->query($sql);// $conn 不能直接调用query
         return $data;
  		
  	}
    public function addVideoInfo(){
    
    $pic=$this->uploadfile("pic",'upload/');

    $videoname=trim($_POST['videoname']);
   $tid=$_POST['tid'];
   $intro=$_POST['intro'];
   $uploaddate=$_POST['uploaddate'];
   
   $address=$_POST['address'];
   
   
   
   // var_dump($_POST);
    $sql="insert into videos values(null,'$videoname','$tid','$pic','$intro','$uploaddate','2','0','0','$address')";
   $result=$this->conn->query($sql);
    return $result;


    }

    public function getVideobyID($vid){
      $vid=$_GET['vid'];
      $sql = "select * from videos where vid=".$vid;
        $result = $this->conn->query($sql);
          return $result;
    }

    public function updateVideoInfo(){
      // 把用户的信息写在数据库
   // 上传头像
    $pic=$this->uploadfile("pic",'upload/');
    
    $vid=$_POST['vid'];
    $videoname=trim($_POST['videoname']);
    $tid=$_POST['tid'];
    $intro=$_POST['intro'];
    $uploaddate=$_POST['uploaddate'];
    $uploadadmin=$_POST['uploadadmin'];
    $hittimes=$_POST['hittimes'];
    $downtimes=$_POST['downtimes'];
    $address=$_POST['address'];

    $sql="update videos set videoname='{$videoname}',tid='{$tid}',pic='{$pic}',intro='{$intro}',address='{$address}' where vid={$vid}";
    // echo $sql;

    $result=$this->conn->query($sql);//写入数据库
    return $result;

  }

  public function delVideo($vid){
      $vid = $_GET['vid'];
      $sql = "delete from videos where vid={$vid}";
      $result = $this->conn->query($sql);
      return $result;
    }
  }

 ?>